this.inDrag = false;
this._selected = false;
+ this._closeRequested = false;
},
set slot(slot) {
deleteAll() {
// Delete all windows, starting from the bottom-most (most-modal) one
-
let windows = this.actor.get_children();
for (let i = windows.length - 1; i >= 1; i--) {
let realWindow = windows[i].source;
}
this.metaWindow.delete(global.get_current_time());
+ this._closeRequested = true;
},
- addAttachedDialog(win) {
- this._doAddAttachedDialog(win, win.get_compositor_private());
- this._onMetaWindowSizeChanged();
+ addDialog(win) {
+ let parent = win.get_transient_for();
+ while (parent.is_attached_dialog())
+ parent = parent.get_transient_for();
+
+ // Display dialog if it is attached to our metaWindow
+ if (win.is_attached_dialog() && parent == this.metaWindow) {
+ this._doAddAttachedDialog(win, win.get_compositor_private());
+ this._onMetaWindowSizeChanged();
+ }
+
+ // The dialog popped up after the user tried to close the window,
+ // assume it's a close confirmation and leave the overview
+ if (this._closeRequested)
+ this._activate();
},
hasAttachedDialogs() {
button._overlap = 0;
this._idleToggleCloseId = 0;
- button.connect('clicked', this._closeWindow.bind(this));
+ button.connect('clicked', () => this._windowClone.deleteAll());
windowClone.actor.connect('destroy', this._onDestroy.bind(this));
windowClone.connect('show-chrome', this._onShowChrome.bind(this));
windowClone.connect('hide-chrome', this._onHideChrome.bind(this));
- this._windowAddedId = 0;
-
button.hide();
title.hide();
Tweener.addTween(actor, params);
},
- _closeWindow(actor) {
- let metaWindow = this._windowClone.metaWindow;
- this._workspace = metaWindow.get_workspace();
-
- this._windowAddedId = this._workspace.connect('window-added',
- this._onWindowAdded.bind(this));
-
- this._windowClone.deleteAll();
- },
-
_windowCanClose() {
return this._windowClone.metaWindow.can_close() &&
!this._windowClone.hasAttachedDialogs();
},
- _onWindowAdded(workspace, win) {
- let metaWindow = this._windowClone.metaWindow;
-
- if (win.get_transient_for() == metaWindow) {
- workspace.disconnect(this._windowAddedId);
- this._windowAddedId = 0;
-
- // use an idle handler to avoid mapping problems -
- // see comment in Workspace._windowAdded
- let id = Mainloop.idle_add(() => {
- this._windowClone.emit('selected');
- return GLib.SOURCE_REMOVE;
- });
- GLib.Source.set_name_by_id(id, '[gnome-shell] this._windowClone.emit');
- }
- },
-
_onDestroy() {
- if (this._windowAddedId > 0) {
- this._workspace.disconnect(this._windowAddedId);
- this._windowAddedId = 0;
- }
if (this._idleToggleCloseId > 0) {
Mainloop.source_remove(this._idleToggleCloseId);
this._idleToggleCloseId = 0;
return;
if (!this._isOverviewWindow(win)) {
- if (metaWin.is_attached_dialog()) {
- let parent = metaWin.get_transient_for();
- while (parent.is_attached_dialog())
- parent = parent.get_transient_for();
-
- let idx = this._lookupIndex (parent);
- if (idx < 0) {
- // parent was not created yet, it will take care
- // of the dialog when created
- return;
- }
+ if (metaWin.get_transient_for() == null)
+ return;
- let clone = this._windows[idx];
- clone.addAttachedDialog(metaWin);
- }
+ // Let the top-most ancestor handle all transients
+ let parent = metaWin.find_root_ancestor();
+ let clone = this._windows.find(c => c.metaWindow == parent);
+
+ // If no clone was found, the parent hasn't been created yet
+ // and will take care of the dialog when added
+ if (clone)
+ clone.addDialog(metaWin);
return;
}